<template>
  <div id="cart">
    <nav-bar class="nav-bar" backColor="#ff8198" fontColor="#fff"
      ><div slot="center">购物车({{ cartCount }})</div></nav-bar
    >
    <div class="cart-item" v-for="item in getCartList" :key="item.iid">
      <div class="checked"></div>
      <img class="image" :src="item.image" />
      <div class="info">
        <div class="title">{{ item.title }}</div>
        <div class="desc">{{ item.desc }}</div>
        <div class="pic-count">
          <div class="pic">￥{{ item.price }}</div>
          <div class="count">x{{ item.count }}</div>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
import NavBar from "components/common/navBar/NavBar";
export default {
  name: "Cart",
  components: {
    NavBar,
  },
  data() {
    return {};
  },
  computed: {
    getCartList() {
      return this.$store.state.shopCart;
    },
    cartCount() {
      return this.getCartList.length;
    },
  },
};
</script>

<style scoped>
.cart-item {
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 120px;
  border-bottom: solid 1px rgba(0, 0, 0, 0.1);
}
.image {
  width: 80px;
  height: 100px;
  border-radius: 5px;
}
.info {
  display: flex;
  flex-direction: column;
  width: 240px;
  font-size: 18px;
  color: black;
}
.title,
.desc {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.desc {
  font-size: 14px;
  color: #666;
  margin: 20px 0;
}
.pic-count {
  display: flex;
  justify-content: space-between;
}
.pic {
  color: orangered;
}
</style>